package com.zzw.bridge.business;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication(scanBasePackages = {"com.zzw"})
@EnableDiscoveryClient
@EnableFeignClients
@Slf4j
public class ZzwBridgeBusinessApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext context = SpringApplication.run(ZzwBridgeBusinessApplication.class, args);
        Environment environment = context.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = environment.getProperty("server.port");
        String path = environment.getProperty("server.servlet.context-path");
        if (!StringUtils.hasLength(path) || "/".equals(path)) {
            path = "";
        }
        log.info("\n----------------------------------------------------------\n\t" +
                "zzw-bridge-business --->启动成功 URLs:\n\t" +
                "API文档网址: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
	}
}
